// -*- c-basic-offset: 2 default-tab-width: 2 indent-tabs-mode: t -*-
// vim: autoindent tabstop=2 noexpandtab shiftwidth=2 softtabstop=2
//===------------ Symbol.h
//
//             This file is part of the reactor project
//                Author: R-Core Team
//
//===---------------------------------------------------------------------===//

#ifndef _SYMBOL_H_
#define _SYMBOL_H_

#include "Any.h"
#include <string>

namespace R {

	class Symbol: public Any {
		BASE_RCLASS(Symbol)
		public:
			char*	text;
			int		length;
			Any*	value;
			virtual void print();
			static Symbol* doNew(int length, char* label); // usage restricted to constant pool or symtable

			Any* getValue() { return value; };
			void setValue(Any* val) { asSelf(Symbol); R_PARAM(val); self->value = val; };

			virtual void tracer(word_t closure);
	};

	class SymbolTable { // TODO a true implementation for symbols
		enum { SYMTABLE_SIZE = 1000 };
		static int size;
		static Symbol **table;
	  private:
		static Symbol *add(int len, char* label);
	  public:
		static void initializeSymbols();
		static Symbol *lookup(int len, char* label);
		static Symbol *lookup(char* label);

		//////////////////// Static Symbols
		static Symbol* threeDots;
	};
}
#endif /* SYMBOL_H_ */
